<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/2/21
 * Time: 16:25
 */

namespace app\admin\model;


use think\Db;

class Comment extends BaseModel
{
    /**
     * 获取列表
     * @param $page
     * @param $pageSize
     * @param $where
     * @param $order
     * @return array
     * @throws \think\exception\DbException
     */
    public static function getPageListByPageWithUser($page,$pageSize,$field,$where,$order)
    {
        $list = Db::name("news_user_comment")->alias("a")
            ->join("comment b","a.comment_id = b.id")
            ->join("news c","c.id = a.news_id")
            ->field($field)
            ->where($where)
            ->order($order)
            ->paginate(array('list_rows' => $pageSize, 'page' => $page))
            ->toArray();
        return $list;
    }

    /**
     * 获取钱十条评论
     * @param $limit
     * @param $order
     * @param $where
     * @param $field
     * @return array|\PDOStatement|string|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function getCommentByLimit($limit,$order,$where,$field)
    {
        $list =  Db::name("news_user_comment")->alias("a")
            ->join("comment b",'a.comment_id = b.id')
            ->where($where)
            ->field($field)
            ->order($order)
            ->limit($limit)
            ->select();
        return  $list;
    }
}